require("../../assets/css/index.less")
require("../../assets/css/common.less");
require("./prj_idt.less")
const request = require("../../lib/requst")
require("../../assets/iconfont/iconfont.css")

function $(select) {
    return document.querySelector(select);
}
let API = "http://fitness.h5.itsource.cn:3701";
window.onload = () => {
    //将课程数据存入本地，供视频播放页面使用
    request.get("/api/train/courseDetail", {
        params: {
            id: location.search.split("=")[1]
        }
    }).then(res => {

        if (res.data.errno === 0) {
            localStorage.setItem("fragments", JSON.stringify(res.data.data.fragments))
        }

    })
    let fragments = JSON.parse(localStorage.getItem("fragments"))
    console.log(fragments[0].videoUrl)
    $("#video").src = API + fragments[0].videoUrl

    let biaogan = true;
    $(".mask").addEventListener("click", function () {
        play();
    })
    //是否播放	
    function play() {
        if (biaogan) {
            video.play();
            $(".startplay").style.display = "none";

        } else {
            video.pause();
            $(".startplay").style.display = "block";
        }
        biaogan = !biaogan;
    }
    $(".to_pre").addEventListener("click",function(){
        history.go(-1);
    })

}